/************************************************************************/
/*    Author: Scott Bevin                                               */
/************************************************************************/


#pragma once
#include "windows.h"
#include <cstdlib>
#include <time.h>
#include <mmsystem.h>

namespace XF
{
	namespace Random
	{
		// Returns an integer value in the range >=0 and <lt
		inline int NextInt(int max)
		{
			return rand() % max;
		}

		// Returns an integer value in the range >=Min and <max
		inline int NextInt(int min, int max)
		{
			return min + rand() % (max - min);
		}
		
		// Returns a float value in the range >=0.0 and <1.0
		inline float NextFloat()
		{
			return (float)rand()/((float)RAND_MAX + 1.0f);
		}

		// Returns a float value in the range >=0.0 and <max
		inline float NextFloat(float max)
		{
			return max * (float)rand()/((float)RAND_MAX + 1.0f);
		}

		// Returns a float value in the range >=Min and <max
		inline float NextFloat(float min, float max)
		{
			return min + (max - min) * ( (float)rand()/((float)RAND_MAX + 1.0f));
		}

		/*
		Start the random numbers from a known seed to get a
		repeatable series of random numbers
		*/
		inline void Seed(int s)
		{
			srand(s);
		}

		inline void Seed()
		{
			srand((unsigned int)time(0));
		}
	}
}